/* ===================================================================
   SOUL PAWS — PHOTO GALLERY (modular)
   -------------------------------------------------------------------
   Self-contained module. Everything is namespaced with `spg-`
   (Soul Paws Gallery) so the whole section can be moved anywhere in
   the page — or removed — without touching the rest of the site.

   Files that make up the module:
     - gallery.css  (this file)
     - gallery.js   (data + rendering + filters + pagination + lightbox)
     - <section id="photo-gallery"> in the HTML (the mount point)
   =================================================================== */

.spg {
  overflow: hidden;
}

/* ---------- Grid ---------- */
.spg-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.spg-tile {
  grid-column: span var(--spg-span, 6);
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-sage-light);
  box-shadow: var(--shadow-soft);
  cursor: zoom-in;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}

/* Each row holds two tiles. The wider one sets the row height (its own
   aspect ratio); the narrower one drops the ratio so it stretches to
   match, keeping every row perfectly flush. */
.spg-tile--fill {
  aspect-ratio: auto;
}

/* A lone tile closing an odd-numbered page runs full width. */
.spg-tile--full {
  aspect-ratio: 16 / 7;
}

/* Taken out of flow so the image never dictates the tile height —
   height comes from the aspect ratio, or from the row for --fill tiles. */
.spg-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.spg-tile:hover {
  box-shadow: var(--shadow-card);
}

.spg-tile:hover img,
.spg-tile:focus-visible img {
  transform: scale(1.04);
}

.spg-tile:focus-visible {
  outline: 3px solid var(--color-dusty-rose-dark);
  outline-offset: 3px;
}

/* Fade-in as each page of tiles is rendered */
.spg-tile {
  opacity: 0;
  animation: spg-fade-in 0.5s ease forwards;
}

@keyframes spg-fade-in {
  to {
    opacity: 1;
  }
}

/* ---------- Pagination ---------- */
.spg-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: var(--space-lg);
}

.spg-page,
.spg-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 0.5rem;
  border: 1px solid var(--color-sage-light);
  border-radius: var(--radius-circle);
  background: var(--color-white);
  color: var(--color-charcoal-light);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-base);
}

.spg-page:hover:not([aria-current='true']),
.spg-arrow:hover:not(:disabled) {
  background: var(--color-lavender-light);
  border-color: var(--color-dusty-rose);
  color: var(--color-charcoal);
}

.spg-page[aria-current='true'] {
  background: #d4acda;
  border-color: #d4acda;
  color: var(--color-white);
  box-shadow: 0 4px 16px rgba(212, 172, 218, 0.4);
  cursor: default;
}

.spg-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.spg-page:focus-visible,
.spg-arrow:focus-visible {
  outline: 2px solid var(--color-dusty-rose-dark);
  outline-offset: 3px;
}

/* ---------- Lightbox ---------- */
.spg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 3rem);
  background: rgba(47, 47, 47, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.spg-lightbox.open {
  opacity: 1;
  visibility: visible;
}

.spg-lightbox img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  object-fit: contain;
}

.spg-lb-btn {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-circle);
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-charcoal);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
}

.spg-lb-btn:hover {
  background: var(--color-white);
  transform: scale(1.08);
}

.spg-lb-btn:focus-visible {
  outline: 2px solid var(--color-white);
  outline-offset: 3px;
}

.spg-lb-close {
  top: clamp(0.75rem, 2.5vw, 1.5rem);
  right: clamp(0.75rem, 2.5vw, 1.5rem);
}

.spg-lb-prev {
  left: clamp(0.5rem, 2vw, 1.5rem);
  top: 50%;
  transform: translateY(-50%);
}

.spg-lb-next {
  right: clamp(0.5rem, 2vw, 1.5rem);
  top: 50%;
  transform: translateY(-50%);
}

.spg-lb-prev:hover,
.spg-lb-next:hover {
  transform: translateY(-50%) scale(1.08);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .spg-grid {
    gap: 0.75rem;
  }

  /* Two even columns — the editorial span pattern is desktop-only */
  .spg-tile,
  .spg-tile--fill,
  .spg-tile--full {
    grid-column: span 6;
    aspect-ratio: 1 / 1;
  }
}

@media (max-width: 560px) {
  .spg-tile,
  .spg-tile--fill,
  .spg-tile--full {
    grid-column: span 12;
    aspect-ratio: 4 / 3;
  }

  .spg-lb-btn {
    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spg-tile {
    opacity: 1;
    animation: none;
  }

  .spg-tile img,
  .spg-lb-btn {
    transition: none;
  }

  .spg-tile:hover img,
  .spg-tile:focus-visible img {
    transform: none;
  }
}
